<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户仪表盘 - ByUsi短链服务</title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .stat-card {
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            transition: transform 0.2s;
        }
        .stat-card:hover {
            transform: translateY(-3px);
        }
        .stat-value {
            font-size: 1.8rem;
            font-weight: bold;
        }
        .shortlink-card {
            border-left: 4px solid #0d6efd;
        }
    </style>
</head>
<body>
    {% include 'navbar.html' %}
    
    <div class="container py-4">
        <h2 class="mb-4">用户仪表盘</h2>
        
        <div class="row mb-4">
            <div class="col-md-6">
                <div class="card stat-card bg-light mb-3">
                    <div class="card-body text-center">
                        <h5 class="card-title">总短链数</h5>
                        <p class="stat-value text-primary">{{ total_links }}</p>
                    </div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="card stat-card bg-light mb-3">
                    <div class="card-body text-center">
                        <h5 class="card-title">总点击量</h5>
                        <p class="stat-value text-success">{{ total_hits }}</p>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="row">
            <div class="col-md-6">
                <div class="card mb-4">
                    <div class="card-header bg-primary text-white">
                        最近创建的短链
                    </div>
                    <div class="card-body">
                        {% if recent_links %}
                        <div class="list-group">
                            {% for link in recent_links %}
                            <div class="list-group-item shortlink-card mb-2">
                                <div class="d-flex w-100 justify-content-between">
                                    <h6 class="mb-1">
                                        <a href="/{{ link[0] }}" target="_blank">{{ request.host_url }}{{ link[0] }}</a>
                                    </h6>
                                    <small>{{ link[2].split(' ')[0] }}</small>
                                </div>
                                <p class="mb-1 text-truncate">{{ link[1] }}</p>
                                <small>点击量: {{ link[3] }}</small>
                            </div>
                            {% endfor %}
                        </div>
                        {% else %}
                        <p class="text-muted">暂无短链</p>
                        {% endif %}
                    </div>
                </div>
            </div>
            
            <div class="col-md-6">
                <div class="card mb-4">
                    <div class="card-header bg-success text-white">
                        热门短链
                    </div>
                    <div class="card-body">
                        {% if top_links %}
                        <div class="list-group">
                            {% for link in top_links %}
                            <div class="list-group-item shortlink-card mb-2">
                                <div class="d-flex w-100 justify-content-between">
                                    <h6 class="mb-1">
                                        <a href="/{{ link[0] }}" target="_blank">{{ request.host_url }}{{ link[0] }}</a>
                                    </h6>
                                </div>
                                <p class="mb-1 text-truncate">{{ link[1] }}</p>
                                <small>点击量: {{ link[2] }}</small>
                            </div>
                            {% endfor %}
                        </div>
                        {% else %}
                        <p class="text-muted">暂无短链</p>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
        
        <div class="text-center mt-3">
            <a href="{{ url_for('index') }}" class="btn btn-outline-secondary">返回首页</a>
            {% if user.get('is_admin') %}
            <a href="{{ url_for('admin_dashboard') }}" class="btn btn-outline-primary ms-2">管理面板</a>
            {% endif %}
        </div>
    </div>
    
    <script src="/static/js/bootstrap.bundle.min.js"></script>
</body>
</html>